package org.harper.bookstore.repo.toplink;

import oracle.toplink.descriptors.ClassDescriptor;
import oracle.toplink.descriptors.RelationalDescriptor;
import oracle.toplink.descriptors.VersionLockingPolicy;
import oracle.toplink.mappings.AggregateObjectMapping;
import oracle.toplink.mappings.DirectToFieldMapping;
import oracle.toplink.mappings.ManyToManyMapping;
import oracle.toplink.mappings.OneToManyMapping;
import oracle.toplink.mappings.OneToOneMapping;
import oracle.toplink.sequencing.TableSequence;
import oracle.toplink.sessions.DatabaseLogin;

import org.harper.bookstore.domain.deliver.ExpressCompany;
import org.harper.bookstore.domain.profile.Book;
import org.harper.bookstore.domain.profile.BookSet;
import org.harper.frm.job.mediator.MediatorDescriptorEventListener;
import org.harper.frm.toplink.EnumConverter;

/**
 * This class was generated by the TopLink project class generator.
 * It stores the meta-data (descriptors) that define the TopLink mappings.
 * ## Oracle TopLink - 10g Release 3 (10.1.3.4.0) (Build 080602) ##
 * @see oracle.toplink.tools.workbench.ProjectClassGenerator
 */

public class BookstoreProject extends oracle.toplink.sessions.Project {

public BookstoreProject() {
	setName("bookstore");
	applyLogin();
	
	addDescriptor(buildAccountingDescriptor());
	addDescriptor(buildBorrowRecordDescriptor());
	addDescriptor(buildLibraryEntryDescriptor());
	addDescriptor(buildRecordDescriptor());
	addDescriptor(buildRecordItemDescriptor());
	addDescriptor(buildReturnRecordDescriptor());
	addDescriptor(buildOrderDescriptor());
	addDescriptor(buildContactInfoDescriptor());
	addDescriptor(buildOrderContactDescriptor());
	addDescriptor(buildOrderItemDescriptor());
	addDescriptor(buildDisplayItemDescriptor());
	addDescriptor(buildPurchaseOrderDescriptor());
	addDescriptor(buildSupplyOrderDescriptor());
	addDescriptor(buildBookDescriptor());
	addDescriptor(buildListPriceDescriptor());
	addDescriptor(buildBookUnit2Descriptor());
	addDescriptor(buildBookSetDescriptor());
	addDescriptor(buildBorrowerDescriptor());
	addDescriptor(buildCustomerDescriptor());
	addDescriptor(buildSupplierDescriptor());
	addDescriptor(buildStoreEntryDescriptor());
	addDescriptor(buildStoreSiteDescriptor());
	addDescriptor(buildTransferDescriptor());
	addDescriptor(buildTransferItemDescriptor());
	addDescriptor(buildDeliveryOrderDescriptor());
	addDescriptor(buildDeliveryItemDescriptor());
	addDescriptor(buildTopLinkCommonRepo$NumGenDescriptor());
	addDescriptor(buildTodoItemDescriptor());
	addDescriptor(buildStockAlertDescriptor());
	addDescriptor(buildStockTakingDescriptor());
	addDescriptor(buildStockTakingItemDescriptor());
	addDescriptor(buildUserDescriptor());
	addDescriptor(buildReceiveOrderDescriptor());
	addDescriptor(buildReceiveOrderItemDescriptor());
	
}



public void applyLogin() {
	DatabaseLogin login = new DatabaseLogin();
	login.usePlatform(new oracle.toplink.platform.database.MySQL4Platform());
	login.setDriverClassName("com.mysql.jdbc.Driver");
	login.setConnectionString("jdbc:mysql://localhost:3306/bookstore");
	login.setUserName("root");
	login.setEncryptedPassword("BF06934E3F151B148BEEB6319A4856D6");
	
	// Configuration Properties.
	
	// Sequencing.
	login.setDefaultSequence(new TableSequence("", 50, "sys_sequence", "table_name", "seq"));
	
	setDatasourceLogin(login);
}

public ClassDescriptor buildAccountingDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.store.StoreSite.class);
	descriptor.addTableName("fna_accounting");
	descriptor.addPrimaryKeyFieldName("fna_accounting.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("fna_accounting.oid");
	descriptor.setSequenceNumberName("fna_accounting");
	descriptor.setAlias("Accounting");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	
	DirectToFieldMapping createDateMapping = new DirectToFieldMapping();
	createDateMapping.setAttributeName("createDate");
	createDateMapping.setFieldName("fna_accounting.create_date");
	descriptor.addMapping(createDateMapping);
	
	DirectToFieldMapping subjectMapping = new DirectToFieldMapping();
	subjectMapping.setAttributeName("subject");
	subjectMapping.setFieldName("fna_accounting.subject");
	descriptor.addMapping(subjectMapping);
	
	DirectToFieldMapping amountMapping = new DirectToFieldMapping();
	amountMapping.setAttributeName("amount");
	amountMapping.setFieldName("fna_accounting.amount");
	descriptor.addMapping(amountMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("store_site.oid");
	descriptor.addMapping(oidMapping);
	
	DirectToFieldMapping refTypeMapping = new DirectToFieldMapping();
	refTypeMapping.setAttributeName("refType");
	refTypeMapping.setFieldName("fna_accounting.ref_type");
	descriptor.addMapping(refTypeMapping);
	
	DirectToFieldMapping refNumberMapping = new DirectToFieldMapping();
	refNumberMapping.setAttributeName("refNumber");
	refNumberMapping.setFieldName("fna_accounting.ref_number");
	descriptor.addMapping(refNumberMapping);
	
	return descriptor;
}

public ClassDescriptor buildBookUnit2Descriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.profile.BookUnit2.class);
	descriptor.setAlias("BookUnit2");
	descriptor.setTableName("profile_book_set");
	descriptor.addPrimaryKeyFieldName("profile_book_set.book_set");
	descriptor.addPrimaryKeyFieldName("profile_book_set.book");
	
	descriptor.useFullIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteFullIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	
	descriptor.addDirectMapping("count", "profile_book_set.count");
	descriptor.addDirectMapping("unitPrice", "profile_book_set.percent");
	
	OneToOneMapping parentMapping = new OneToOneMapping();
	parentMapping.setReferenceClass(BookSet.class);
	parentMapping.setAttributeName("parent");
	parentMapping.dontUseIndirection();
	parentMapping.addForeignKeyFieldName("profile_book_set.book_set", "profile_book.oid");
	descriptor.addMapping(parentMapping);
	
	OneToOneMapping bookMapping = new OneToOneMapping();
	bookMapping.setReferenceClass(Book.class);
	bookMapping.setAttributeName("book");
	bookMapping.dontUseIndirection();
	bookMapping.addForeignKeyFieldName("profile_book_set.book", "profile_book.oid");
	descriptor.addMapping(bookMapping);
	
	return descriptor;
}

public ClassDescriptor buildBookDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.profile.Book.class);
	descriptor.addTableName("profile_book");
	descriptor.addPrimaryKeyFieldName("profile_book.oid");
	
	// Descriptor Properties.
	descriptor.useFullIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteFullIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("profile_book.oid");
	descriptor.setSequenceNumberName("profile_book");
	descriptor.setAlias("Book");
	
	// Inheritance Properties.
	descriptor.getInheritancePolicy().setClassIndicatorFieldName("profile_book.is_set");
	descriptor.getInheritancePolicy().addClassIndicator(org.harper.bookstore.domain.profile.Book.class, "0");
	descriptor.getInheritancePolicy().addClassIndicator(org.harper.bookstore.domain.profile.BookSet.class, "1");
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	DirectToFieldMapping weightMapping = new DirectToFieldMapping();
	weightMapping.setAttributeName("weight");
	weightMapping.setFieldName("profile_book.weight");
	descriptor.addMapping(weightMapping);
	
	DirectToFieldMapping pageMapping = new DirectToFieldMapping();
	pageMapping.setAttributeName("page");
	pageMapping.setFieldName("profile_book.page");
	descriptor.addMapping(pageMapping);
	
	DirectToFieldMapping descMapping = new DirectToFieldMapping();
	descMapping.setAttributeName("desc");
	descMapping.setFieldName("profile_book.description");
	descriptor.addMapping(descMapping);
	
	DirectToFieldMapping isbnMapping = new DirectToFieldMapping();
	isbnMapping.setAttributeName("isbn");
	isbnMapping.setFieldName("profile_book.isbn");
	descriptor.addMapping(isbnMapping);
	
	DirectToFieldMapping nameMapping = new DirectToFieldMapping();
	nameMapping.setAttributeName("name");
	nameMapping.setFieldName("profile_book.name");
	descriptor.addMapping(nameMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("profile_book.oid");
	descriptor.addMapping(oidMapping);
	
	return descriptor;
}

public ClassDescriptor buildContactInfoDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.descriptorIsAggregate();
	descriptor.setJavaClass(org.harper.bookstore.domain.profile.ContactInfo.class);
	
	// Descriptor Properties.
	descriptor.setAlias("ContactInfo");
	
	// Query Manager.
	
	// Event Manager.
	
	// Mappings.
	descriptor.addDirectMapping("name","name");
	descriptor.addDirectMapping("email","email");
	descriptor.addDirectMapping("address","address");
	descriptor.addDirectMapping("phone","phone_normal");
	descriptor.addDirectMapping("mobile","phone_mobile");
	descriptor.addDirectMapping("postalCode","post_code");
	
	return descriptor;
}

public ClassDescriptor buildOrderContactDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.order.OrderContact.class);
	descriptor.addTableName("order_contact");
	descriptor.addPrimaryKeyFieldName("order_contact.order_oid");
	
	// Descriptor Properties.
	descriptor.useFullIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteFullIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setAlias("OrderContact");
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	descriptor.addDirectMapping("name","name");
	descriptor.addDirectMapping("email","email");
	descriptor.addDirectMapping("address","address");
	descriptor.addDirectMapping("phone","phone_normal");
	descriptor.addDirectMapping("mobile","phone_mobile");
	descriptor.addDirectMapping("postalCode","post_code");
	
	OneToOneMapping orderMapping = new OneToOneMapping();
	orderMapping.setAttributeName("order");
	orderMapping.setReferenceClass(org.harper.bookstore.domain.order.Order.class);
	orderMapping.dontUseIndirection();
	orderMapping.addForeignKeyFieldName("order_contact.order_oid", "order_common.oid");
	descriptor.addMapping(orderMapping);
	
	return descriptor;
}

public ClassDescriptor buildBookSetDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.profile.BookSet.class);
	descriptor.addTableName("profile_book");
	
	// Inheritance Properties.
	descriptor.getInheritancePolicy().setParentClass(org.harper.bookstore.domain.profile.Book.class);
	
	// Descriptor Properties.
	descriptor.setAlias("BookSet");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	OneToManyMapping booksMapping = new OneToManyMapping();
	booksMapping.setAttributeName("books");
	booksMapping.setReferenceClass(org.harper.bookstore.domain.profile.BookUnit2.class);
	booksMapping.useTransparentCollection();
	booksMapping.useCollectionClass(oracle.toplink.indirection.IndirectList.class);
	booksMapping.addTargetForeignKeyFieldName("profile_book_set.book_set", "profile_book.oid");
	
	descriptor.addMapping(booksMapping);
	
	return descriptor;
}

public ClassDescriptor buildBorrowRecordDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.library.BorrowRecord.class);
	descriptor.addTableName("library_record");
	
	// Inheritance Properties.
	descriptor.getInheritancePolicy().setParentClass(org.harper.bookstore.domain.library.Record.class);
	
	// Descriptor Properties.
	descriptor.setAlias("BorrowRecord");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	return descriptor;
}

public ClassDescriptor buildBorrowerDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.profile.Borrower.class);
	descriptor.addTableName("profile_borrower");
	descriptor.addPrimaryKeyFieldName("profile_borrower.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("profile_borrower.oid");
	descriptor.setSequenceNumberName("profile_borrower");
	descriptor.setAlias("Borrower");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
//	DirectToFieldMapping companyMapping = new DirectToFieldMapping();
//	companyMapping.setAttributeName("company");
//	companyMapping.setFieldName("profile_borrower.company");
//	descriptor.addMapping(companyMapping);
	
	DirectToFieldMapping nameMapping = new DirectToFieldMapping();
	nameMapping.setAttributeName("name");
	nameMapping.setFieldName("profile_borrower.name");
	descriptor.addMapping(nameMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("profile_borrower.oid");
	descriptor.addMapping(oidMapping);
	
	return descriptor;
}

public ClassDescriptor buildCustomerDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.profile.Customer.class);
	descriptor.addTableName("profile_customer");
	descriptor.addPrimaryKeyFieldName("profile_customer.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("profile_customer.oid");
	descriptor.setSequenceNumberName("profile_customer");
	descriptor.setAlias("Customer");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	DirectToFieldMapping idMapping = new DirectToFieldMapping();
	idMapping.setAttributeName("id");
	idMapping.setFieldName("profile_customer.customer_id");
	descriptor.addMapping(idMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("profile_customer.oid");
	descriptor.addMapping(oidMapping);
	
	DirectToFieldMapping sourceMapping = new DirectToFieldMapping();
	sourceMapping.setAttributeName("source");
	sourceMapping.setFieldName("profile_customer.source");
	descriptor.addMapping(sourceMapping);
	
	return descriptor;
}

public ClassDescriptor buildLibraryEntryDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.library.LibraryEntry.class);
	descriptor.addTableName("library_entry");
	descriptor.addPrimaryKeyFieldName("library_entry.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("library_entry.oid");
	descriptor.setSequenceNumberName("library_entry");
	descriptor.setAlias("LibraryEntry");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("library_entry.oid");
	descriptor.addMapping(oidMapping);
	
	DirectToFieldMapping outstandingMapping = new DirectToFieldMapping();
	outstandingMapping.setAttributeName("outstanding");
	outstandingMapping.setFieldName("library_entry.ost");
	descriptor.addMapping(outstandingMapping);
	
	DirectToFieldMapping totalMapping = new DirectToFieldMapping();
	totalMapping.setAttributeName("total");
	totalMapping.setFieldName("library_entry.count");
	descriptor.addMapping(totalMapping);
	
	OneToOneMapping bookMapping = new OneToOneMapping();
	bookMapping.setAttributeName("book");
	bookMapping.setReferenceClass(org.harper.bookstore.domain.profile.Book.class);
	bookMapping.dontUseIndirection();
	bookMapping.addForeignKeyFieldName("library_entry.book_oid", "profile_book.oid");
	descriptor.addMapping(bookMapping);
	
	return descriptor;
}

public ClassDescriptor buildOrderDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.order.Order.class);
	descriptor.addTableName("order_common");
	descriptor.addPrimaryKeyFieldName("order_common.oid");
	
	// Inheritance Properties.
	descriptor.getInheritancePolicy().setClassIndicatorFieldName("order_common.order_type");
	descriptor.getInheritancePolicy().addClassIndicator(org.harper.bookstore.domain.order.SupplyOrder.class, "S");
	descriptor.getInheritancePolicy().addClassIndicator(org.harper.bookstore.domain.order.PurchaseOrder.class, "B");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("order_common.oid");
	descriptor.setSequenceNumberName("order_common");
	descriptor.setAlias("Order");
	
	VersionLockingPolicy vp = new VersionLockingPolicy();
	vp.setIsStoredInCache(false);
	vp.setWriteLockFieldName("order_common.version");
	descriptor.setOptimisticLockingPolicy(vp);
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	descriptor.addDirectMapping("feeName","order_common.fee_name");
	descriptor.addDirectMapping("version","order_common.version");
	descriptor.addDirectMapping("feeAmount","order_common.fee_amount");
	descriptor.addDirectMapping("remark","order_common.remark");
	descriptor.addDirectMapping("memo","order_common.memo");
	descriptor.addDirectMapping("refno","order_common.refno");
	
	DirectToFieldMapping createDateMapping = new DirectToFieldMapping();
	createDateMapping.setAttributeName("createDate");
	createDateMapping.setFieldName("order_common.create_date");
	descriptor.addMapping(createDateMapping);
	
	DirectToFieldMapping numberMapping = new DirectToFieldMapping();
	numberMapping.setAttributeName("number");
	numberMapping.setFieldName("order_common.number");
	descriptor.addMapping(numberMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("order_common.oid");
	descriptor.addMapping(oidMapping);
	
	DirectToFieldMapping totalAmtMapping = new DirectToFieldMapping();
	totalAmtMapping.setAttributeName("totalAmt");
	totalAmtMapping.setFieldName("order_common.total_amt");
	descriptor.addMapping(totalAmtMapping);
	
	DirectToFieldMapping statusMapping = new DirectToFieldMapping();
	statusMapping.setAttributeName("status");
	statusMapping.setFieldName("order_common.status");
	descriptor.addMapping(statusMapping);
	
	OneToOneMapping siteMapping = new OneToOneMapping();
	siteMapping.setAttributeName("site");
	siteMapping.setReferenceClass(org.harper.bookstore.domain.store.StoreSite.class);
	siteMapping.dontUseIndirection();
	siteMapping.addForeignKeyFieldName("order_common.site", "store_site.oid");
	descriptor.addMapping(siteMapping);
	
	OneToOneMapping contactMapping = new OneToOneMapping();
	contactMapping.setAttributeName("contact");
	contactMapping.setReferenceClass(org.harper.bookstore.domain.order.OrderContact.class);
	contactMapping.dontUseIndirection();
	contactMapping.addTargetForeignKeyFieldName("order_contact.order_oid", "order_common.oid");
	descriptor.addMapping(contactMapping);
	
	
	OneToManyMapping itemsMapping = new OneToManyMapping();
	itemsMapping.setAttributeName("items");
	itemsMapping.setReferenceClass(org.harper.bookstore.domain.order.OrderItem.class);
	itemsMapping.privateOwnedRelationship();
	itemsMapping.useTransparentCollection();
	itemsMapping.useCollectionClass(oracle.toplink.indirection.IndirectList.class);
	itemsMapping.addTargetForeignKeyFieldName("order_item.order_header", "order_common.oid");
	descriptor.addMapping(itemsMapping);
	
	return descriptor;
}

public ClassDescriptor buildOrderItemDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.order.OrderItem.class);
	descriptor.addTableName("order_item");
	descriptor.addPrimaryKeyFieldName("order_item.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("order_item.oid");
	descriptor.setSequenceNumberName("order_item");
	descriptor.setAlias("OrderItem");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
//	DirectToFieldMapping displaySequenceMapping = new DirectToFieldMapping();
//	displaySequenceMapping.setAttributeName("displaySequence");
//	displaySequenceMapping.setFieldName("order_item.disp_seq");
//	descriptor.addMapping(displaySequenceMapping);
	
	DirectToFieldMapping countMapping = new DirectToFieldMapping();
	countMapping.setAttributeName("count");
	countMapping.setFieldName("order_item.count");
	descriptor.addMapping(countMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("order_item.oid");
	descriptor.addMapping(oidMapping);
	
	DirectToFieldMapping unitCostMapping = new DirectToFieldMapping();
	unitCostMapping.setAttributeName("unitCost");
	unitCostMapping.setFieldName("order_item.unit_cost");
	descriptor.addMapping(unitCostMapping);
	
	DirectToFieldMapping sentCountMapping = new DirectToFieldMapping();
	sentCountMapping.setAttributeName("sentCount");
	sentCountMapping.setFieldName("order_item.sent_count");
	descriptor.addMapping(sentCountMapping);
	
	DirectToFieldMapping agentMapping = new DirectToFieldMapping();
	agentMapping.setAttributeName("agent");
	agentMapping.setFieldName("order_item.is_agent");
	descriptor.addMapping(agentMapping);
	
	DirectToFieldMapping unitPriceMapping = new DirectToFieldMapping();
	unitPriceMapping.setAttributeName("unitPrice");
	unitPriceMapping.setFieldName("order_item.unit_price");
	descriptor.addMapping(unitPriceMapping);
	
	OneToOneMapping bookMapping = new OneToOneMapping();
	bookMapping.setAttributeName("book");
	bookMapping.setReferenceClass(org.harper.bookstore.domain.profile.Book.class);
	bookMapping.dontUseIndirection();
	bookMapping.addForeignKeyFieldName("order_item.book_oid", "profile_book.oid");
	descriptor.addMapping(bookMapping);
	
	OneToOneMapping orderMapping = new OneToOneMapping();
	orderMapping.setAttributeName("order");
	orderMapping.setReferenceClass(org.harper.bookstore.domain.order.Order.class);
	orderMapping.dontUseIndirection();
	orderMapping.addForeignKeyFieldName("order_item.order_header", "order_common.oid");
	descriptor.addMapping(orderMapping);
	
	return descriptor;
}

public ClassDescriptor buildDisplayItemDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.order.DisplayItem.class);
	descriptor.addTableName("order_disp_item");
	descriptor.addPrimaryKeyFieldName("order_disp_item.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("order_disp_item.oid");
	descriptor.setSequenceNumberName("order_disp_item");
	descriptor.setAlias("DisplayItem");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	DirectToFieldMapping countMapping = new DirectToFieldMapping();
	countMapping.setAttributeName("count");
	countMapping.setFieldName("order_disp_item.count");
	descriptor.addMapping(countMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("order_disp_item.oid");
	descriptor.addMapping(oidMapping);
	
	DirectToFieldMapping nameMapping = new DirectToFieldMapping();
	nameMapping.setAttributeName("name");
	nameMapping.setFieldName("order_disp_item.name");
	descriptor.addMapping(nameMapping);
	
	DirectToFieldMapping unitPriceMapping = new DirectToFieldMapping();
	unitPriceMapping.setAttributeName("unitPrice");
	unitPriceMapping.setFieldName("order_disp_item.unit_price");
	descriptor.addMapping(unitPriceMapping);
	
	DirectToFieldMapping actualPriceMapping = new DirectToFieldMapping();
	actualPriceMapping.setAttributeName("actualPrice");
	actualPriceMapping.setFieldName("order_disp_item.actual_price");
	descriptor.addMapping(actualPriceMapping);
	
	OneToOneMapping orderMapping = new OneToOneMapping();
	orderMapping.setAttributeName("order");
	orderMapping.setReferenceClass(org.harper.bookstore.domain.order.PurchaseOrder.class);
	orderMapping.dontUseIndirection();
	orderMapping.addForeignKeyFieldName("order_disp_item.order_header", "order_common.oid");
	descriptor.addMapping(orderMapping);
	
	return descriptor;
}

public ClassDescriptor buildPurchaseOrderDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.order.PurchaseOrder.class);
	descriptor.addTableName("order_common");
	
	// Inheritance Properties.
	descriptor.getInheritancePolicy().setParentClass(org.harper.bookstore.domain.order.Order.class);
	
	// Descriptor Properties.
	descriptor.setAlias("PurchaseOrder");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	descriptor.addDirectMapping("refStatus","order_common.ref_status");
	descriptor.addDirectMapping("deliveryStatus","order_common.delivery_status");
	
	OneToOneMapping customerMapping = new OneToOneMapping();
	customerMapping.setAttributeName("customer");
	customerMapping.setReferenceClass(org.harper.bookstore.domain.profile.Customer.class);
	customerMapping.dontUseIndirection();
	customerMapping.addForeignKeyFieldName("order_common.customer", "profile_customer.oid");
	descriptor.addMapping(customerMapping);
	
	OneToOneMapping deliveryMapping = new OneToOneMapping();
	deliveryMapping.setReferenceClass(org.harper.bookstore.domain.deliver.DeliveryOrder.class);
	deliveryMapping.useBasicIndirection();
	deliveryMapping.setAttributeName("delivery");
	deliveryMapping.addForeignKeyFieldName("order_common.purchase_deliver","order_delivery.oid");
	descriptor.addMapping(deliveryMapping);
	
	OneToManyMapping dispItemsMapping = new OneToManyMapping();
	dispItemsMapping.setAttributeName("dispItems");
	dispItemsMapping.setReferenceClass(org.harper.bookstore.domain.order.DisplayItem.class);
	dispItemsMapping.privateOwnedRelationship();
	dispItemsMapping.useTransparentCollection();
	dispItemsMapping.useCollectionClass(oracle.toplink.indirection.IndirectList.class);
	dispItemsMapping.addTargetForeignKeyFieldName("order_disp_item.order_header", "order_common.oid");
	descriptor.addMapping(dispItemsMapping);
	
	ManyToManyMapping deliveryOrdersMapping = new ManyToManyMapping();
	deliveryOrdersMapping.setAttributeName("deliveryOrders");
	deliveryOrdersMapping.setReferenceClass(org.harper.bookstore.domain.deliver.DeliveryOrder.class);
	deliveryOrdersMapping.setRelationTableName("order_delivery_po");
	deliveryOrdersMapping.addSourceRelationKeyFieldName("order_delivery_po.po_oid", "order_common.oid");
	deliveryOrdersMapping.addTargetRelationKeyFieldName("order_delivery_po.do_oid", "order_delivery.oid");
	deliveryOrdersMapping.useBasicIndirection();
	descriptor.addMapping(deliveryOrdersMapping);
	
	return descriptor;
}

public ClassDescriptor buildRecordDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.library.Record.class);
	descriptor.addTableName("library_record");
	descriptor.addPrimaryKeyFieldName("library_record.oid");
	
	// Inheritance Properties.
	descriptor.getInheritancePolicy().setClassIndicatorFieldName("library_record.type");
	descriptor.getInheritancePolicy().addClassIndicator(org.harper.bookstore.domain.library.BorrowRecord.class, "B");
	descriptor.getInheritancePolicy().addClassIndicator(org.harper.bookstore.domain.library.ReturnRecord.class, "R");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("library_record.oid");
	descriptor.setSequenceNumberName("library_record");
	descriptor.setAlias("Record");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	DirectToFieldMapping accountDateMapping = new DirectToFieldMapping();
	accountDateMapping.setAttributeName("accountDate");
	accountDateMapping.setFieldName("library_record.acc_date");
	descriptor.addMapping(accountDateMapping);
	
	DirectToFieldMapping closeDateMapping = new DirectToFieldMapping();
	closeDateMapping.setAttributeName("closeDate");
	closeDateMapping.setFieldName("library_record.close_date");
	descriptor.addMapping(closeDateMapping);
	
	DirectToFieldMapping closeReasonMapping = new DirectToFieldMapping();
	closeReasonMapping.setAttributeName("closeReason");
	closeReasonMapping.setFieldName("library_record.close_reason");
	descriptor.addMapping(closeReasonMapping);
	
	DirectToFieldMapping numberMapping = new DirectToFieldMapping();
	numberMapping.setAttributeName("number");
	numberMapping.setFieldName("library_record.rec_number");
	descriptor.addMapping(numberMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("library_record.oid");
	descriptor.addMapping(oidMapping);
	
	DirectToFieldMapping remarkMapping = new DirectToFieldMapping();
	remarkMapping.setAttributeName("remark");
	remarkMapping.setFieldName("library_record.remark");
	descriptor.addMapping(remarkMapping);
	
	DirectToFieldMapping statusMapping = new DirectToFieldMapping();
	statusMapping.setAttributeName("status");
	statusMapping.setFieldName("library_record.status");
	descriptor.addMapping(statusMapping);

	OneToOneMapping siteMapping = new OneToOneMapping();
	siteMapping.setAttributeName("site");
	siteMapping.setReferenceClass(org.harper.bookstore.domain.store.StoreSite.class);
	siteMapping.dontUseIndirection();
	siteMapping.addForeignKeyFieldName("library_record.site", "store_site.oid");
	descriptor.addMapping(siteMapping);
	
	OneToOneMapping borrowerMapping = new OneToOneMapping();
	borrowerMapping.setAttributeName("borrower");
	borrowerMapping.setReferenceClass(org.harper.bookstore.domain.profile.Borrower.class);
	borrowerMapping.dontUseIndirection();
	borrowerMapping.addForeignKeyFieldName("library_record.borrower", "profile_borrower.oid");
	descriptor.addMapping(borrowerMapping);
	
	OneToManyMapping itemsMapping = new OneToManyMapping();
	itemsMapping.setAttributeName("items");
	itemsMapping.setReferenceClass(org.harper.bookstore.domain.library.RecordItem.class);
	itemsMapping.useTransparentCollection();
	itemsMapping.useCollectionClass(oracle.toplink.indirection.IndirectList.class);
	itemsMapping.addTargetForeignKeyFieldName("library_record_item.header", "library_record.oid");
	descriptor.addMapping(itemsMapping);
	
	return descriptor;
}

public ClassDescriptor buildRecordItemDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.library.RecordItem.class);
	descriptor.addTableName("library_record_item");
	descriptor.addPrimaryKeyFieldName("library_record_item.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("library_record_item.oid");
	descriptor.setSequenceNumberName("library_record_item");
	descriptor.setAlias("RecordItem");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	DirectToFieldMapping closeDateMapping = new DirectToFieldMapping();
	closeDateMapping.setAttributeName("closeDate");
	closeDateMapping.setFieldName("library_record_item.close_date");
	descriptor.addMapping(closeDateMapping);
	
	DirectToFieldMapping countMapping = new DirectToFieldMapping();
	countMapping.setAttributeName("count");
	countMapping.setFieldName("library_record_item.book_count");
	descriptor.addMapping(countMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("library_record_item.oid");
	descriptor.addMapping(oidMapping);
	
	DirectToFieldMapping outstandingMapping = new DirectToFieldMapping();
	outstandingMapping.setAttributeName("outstanding");
	outstandingMapping.setFieldName("library_record_item.ost");
	descriptor.addMapping(outstandingMapping);
	
	DirectToFieldMapping statusMapping = new DirectToFieldMapping();
	statusMapping.setAttributeName("status");
	statusMapping.setFieldName("library_record_item.status");
	descriptor.addMapping(statusMapping);
	
	OneToOneMapping balanceToMapping = new OneToOneMapping();
	balanceToMapping.setAttributeName("balanceTo");
	balanceToMapping.setReferenceClass(org.harper.bookstore.domain.library.RecordItem.class);
	balanceToMapping.dontUseIndirection();
	balanceToMapping.addForeignKeyFieldName("library_record_item.balance_to", "library_record_item.oid");
	descriptor.addMapping(balanceToMapping);
	
	OneToOneMapping bookMapping = new OneToOneMapping();
	bookMapping.setAttributeName("book");
	bookMapping.setReferenceClass(org.harper.bookstore.domain.profile.Book.class);
	bookMapping.dontUseIndirection();
	bookMapping.addForeignKeyFieldName("library_record_item.book_oid", "profile_book.oid");
	descriptor.addMapping(bookMapping);
	
	OneToOneMapping headerMapping = new OneToOneMapping();
	headerMapping.setAttributeName("header");
	headerMapping.setReferenceClass(org.harper.bookstore.domain.library.Record.class);
	headerMapping.dontUseIndirection();
	headerMapping.addForeignKeyFieldName("library_record_item.header", "library_record.oid");
	descriptor.addMapping(headerMapping);
	
	return descriptor;
}

public ClassDescriptor buildReturnRecordDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.library.ReturnRecord.class);
	descriptor.addTableName("library_record");
	
	// Inheritance Properties.
	descriptor.getInheritancePolicy().setParentClass(org.harper.bookstore.domain.library.Record.class);
	
	// Descriptor Properties.
	descriptor.setAlias("ReturnRecord");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	return descriptor;
}

public ClassDescriptor buildStoreEntryDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.store.StoreEntry.class);
	descriptor.addTableName("store_entry");
	descriptor.addPrimaryKeyFieldName("store_entry.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("store_entry.oid");
	descriptor.setSequenceNumberName("store_entry");
	descriptor.setAlias("StoreEntry");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	descriptor.getDescriptorEventManager().addListener(MediatorDescriptorEventListener.INSTANCE);
	
	// Mappings.
	DirectToFieldMapping countMapping = new DirectToFieldMapping();
	countMapping.setAttributeName("count");
	countMapping.setFieldName("store_entry.count");
	descriptor.addMapping(countMapping);
	
	DirectToFieldMapping lockedCountMapping = new DirectToFieldMapping();
	lockedCountMapping.setAttributeName("lockedCount");
	lockedCountMapping.setFieldName("store_entry.locked_count");
	descriptor.addMapping(lockedCountMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("store_entry.oid");
	descriptor.addMapping(oidMapping);
	
	DirectToFieldMapping unitPriceMapping = new DirectToFieldMapping();
	unitPriceMapping.setAttributeName("unitPrice");
	unitPriceMapping.setFieldName("store_entry.unit_price");
	descriptor.addMapping(unitPriceMapping);
	
	OneToOneMapping bookMapping = new OneToOneMapping();
	bookMapping.setAttributeName("book");
	bookMapping.setReferenceClass(org.harper.bookstore.domain.profile.Book.class);
	bookMapping.dontUseIndirection();
	bookMapping.addForeignKeyFieldName("store_entry.book_oid", "profile_book.oid");
	descriptor.addMapping(bookMapping);
	
	OneToOneMapping siteMapping = new OneToOneMapping();
	siteMapping.setAttributeName("site");
	siteMapping.setReferenceClass(org.harper.bookstore.domain.store.StoreSite.class);
	siteMapping.dontUseIndirection();
	siteMapping.addForeignKeyFieldName("store_entry.site", "store_site.oid");
	descriptor.addMapping(siteMapping);
	
	return descriptor;
}

public ClassDescriptor buildStoreSiteDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.store.StoreSite.class);
	descriptor.addTableName("store_site");
	descriptor.addPrimaryKeyFieldName("store_site.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("store_site.oid");
	descriptor.setSequenceNumberName("store_site");
	descriptor.setAlias("StoreSite");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	descriptor.addDirectMapping("forOutput", "store_site.for_output");
	
	DirectToFieldMapping nameMapping = new DirectToFieldMapping();
	nameMapping.setAttributeName("name");
	nameMapping.setFieldName("store_site.name");
	descriptor.addMapping(nameMapping);
	
	DirectToFieldMapping descriptionMapping = new DirectToFieldMapping();
	descriptionMapping.setAttributeName("description");
	descriptionMapping.setFieldName("store_site.description");
	descriptor.addMapping(descriptionMapping);
	
	DirectToFieldMapping validMapping = new DirectToFieldMapping();
	validMapping.setAttributeName("valid");
	validMapping.setFieldName("store_site.valid");
	descriptor.addMapping(validMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("store_site.oid");
	descriptor.addMapping(oidMapping);
	
	DirectToFieldMapping privilegeMapping = new DirectToFieldMapping();
	privilegeMapping.setAttributeName("privilege");
	privilegeMapping.setFieldName("store_site.pref_seq");
	descriptor.addMapping(privilegeMapping);
	
	OneToManyMapping entriesMapping = new OneToManyMapping();
	entriesMapping.setAttributeName("entries");
	entriesMapping.setReferenceClass(org.harper.bookstore.domain.store.StoreEntry.class);
	entriesMapping.privateOwnedRelationship();
	entriesMapping.useTransparentCollection();
	entriesMapping.useCollectionClass(oracle.toplink.indirection.IndirectList.class);
	entriesMapping.addTargetForeignKeyFieldName("store_entry.site", "store_site.oid");
	descriptor.addMapping(entriesMapping);
	
	return descriptor;
}

public ClassDescriptor buildListPriceDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.order.ListPrice.class);
	descriptor.addTableName("order_list_price");
	descriptor.addPrimaryKeyFieldName("order_list_price.book_oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setAlias("order_list_price");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	DirectToFieldMapping priceMapping = new DirectToFieldMapping();
	priceMapping.setAttributeName("price");
	priceMapping.setFieldName("order_list_price.list_price");
	descriptor.addMapping(priceMapping);
	
	OneToOneMapping bookMapping = new OneToOneMapping();
	bookMapping.setAttributeName("book");
	bookMapping.dontUseIndirection();
	bookMapping.setReferenceClass(org.harper.bookstore.domain.profile.Book.class);
	bookMapping.addForeignKeyFieldName("order_list_price.book_oid", "profile_book.oid");
	descriptor.addMapping(bookMapping);
	
	return descriptor;
}

public ClassDescriptor buildSupplierDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.profile.Supplier.class);
	descriptor.addTableName("profile_supplier");
	descriptor.addPrimaryKeyFieldName("profile_supplier.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("profile_supplier.oid");
	descriptor.setSequenceNumberName("profile_supplier");
	descriptor.setAlias("Supplier");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	DirectToFieldMapping idMapping = new DirectToFieldMapping();
	idMapping.setAttributeName("id");
	idMapping.setFieldName("profile_supplier.id");
	descriptor.addMapping(idMapping);
	
	DirectToFieldMapping nameMapping = new DirectToFieldMapping();
	nameMapping.setAttributeName("name");
	nameMapping.setFieldName("profile_supplier.name");
	descriptor.addMapping(nameMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("profile_supplier.oid");
	descriptor.addMapping(oidMapping);
	
	DirectToFieldMapping sourceMapping = new DirectToFieldMapping();
	sourceMapping.setAttributeName("source");
	sourceMapping.setFieldName("profile_supplier.source");
	descriptor.addMapping(sourceMapping);
	
	return descriptor;
}

public ClassDescriptor buildSupplyOrderDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.order.SupplyOrder.class);
	descriptor.addTableName("order_common");
	
	// Inheritance Properties.
	descriptor.getInheritancePolicy().setParentClass(org.harper.bookstore.domain.order.Order.class);
	
	// Descriptor Properties.
	descriptor.setAlias("SupplyOrder");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	
	OneToOneMapping supplierMapping = new OneToOneMapping();
	supplierMapping.setAttributeName("supplier");
	supplierMapping.setReferenceClass(org.harper.bookstore.domain.profile.Supplier.class);
	supplierMapping.dontUseIndirection();
	supplierMapping.addForeignKeyFieldName("order_common.provider", "profile_supplier.oid");
	descriptor.addMapping(supplierMapping);
	
	return descriptor;
}

public ClassDescriptor buildTopLinkCommonRepo$NumGenDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.repo.toplink.TopLinkCommonRepo.NumGen.class);
	descriptor.addTableName("sys_num_gen");
	descriptor.addPrimaryKeyFieldName("sys_num_gen.type");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setAlias("TopLinkCommonRepo$NumGen");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	DirectToFieldMapping currentMapping = new DirectToFieldMapping();
	currentMapping.setAttributeName("current");
	currentMapping.setFieldName("sys_num_gen.current");
	descriptor.addMapping(currentMapping);
	
	DirectToFieldMapping lengthMapping = new DirectToFieldMapping();
	lengthMapping.setAttributeName("length");
	lengthMapping.setFieldName("sys_num_gen.length");
	descriptor.addMapping(lengthMapping);
	
	DirectToFieldMapping prefixMapping = new DirectToFieldMapping();
	prefixMapping.setAttributeName("prefix");
	prefixMapping.setFieldName("sys_num_gen.prefix");
	descriptor.addMapping(prefixMapping);
	
	DirectToFieldMapping suffixMapping = new DirectToFieldMapping();
	suffixMapping.setAttributeName("suffix");
	suffixMapping.setFieldName("sys_num_gen.suffix");
	descriptor.addMapping(suffixMapping);
	
	DirectToFieldMapping typeMapping = new DirectToFieldMapping();
	typeMapping.setAttributeName("type");
	typeMapping.setFieldName("sys_num_gen.type");
	descriptor.addMapping(typeMapping);
	
	return descriptor;
}

public ClassDescriptor buildTransferDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.store.Transfer.class);
	descriptor.addTableName("store_transfer");
	descriptor.addPrimaryKeyFieldName("store_transfer.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("store_transfer.oid");
	descriptor.setSequenceNumberName("store_transfer");
	descriptor.setAlias("Transfer");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	DirectToFieldMapping actionDateMapping = new DirectToFieldMapping();
	actionDateMapping.setAttributeName("actionDate");
	actionDateMapping.setFieldName("store_transfer.action_date");
	descriptor.addMapping(actionDateMapping);
	
	DirectToFieldMapping createDateMapping = new DirectToFieldMapping();
	createDateMapping.setAttributeName("createDate");
	createDateMapping.setFieldName("store_transfer.create_date");
	descriptor.addMapping(createDateMapping);
	
	DirectToFieldMapping expectActionDateMapping = new DirectToFieldMapping();
	expectActionDateMapping.setAttributeName("expectActionDate");
	expectActionDateMapping.setFieldName("store_transfer.expect_action_date");
	descriptor.addMapping(expectActionDateMapping);
	
	DirectToFieldMapping numberMapping = new DirectToFieldMapping();
	numberMapping.setAttributeName("number");
	numberMapping.setFieldName("store_transfer.tr_number");
	descriptor.addMapping(numberMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("store_transfer.oid");
	descriptor.addMapping(oidMapping);
	
	DirectToFieldMapping statusMapping = new DirectToFieldMapping();
	statusMapping.setAttributeName("status");
	statusMapping.setFieldName("store_transfer.status");
	descriptor.addMapping(statusMapping);
	
	OneToOneMapping fromSiteMapping = new OneToOneMapping();
	fromSiteMapping.setAttributeName("fromSite");
	fromSiteMapping.setReferenceClass(org.harper.bookstore.domain.store.StoreSite.class);
	fromSiteMapping.dontUseIndirection();
	fromSiteMapping.addForeignKeyFieldName("store_transfer.from_site", "store_site.oid");
	descriptor.addMapping(fromSiteMapping);
	
	OneToOneMapping toSiteMapping = new OneToOneMapping();
	toSiteMapping.setAttributeName("toSite");
	toSiteMapping.setReferenceClass(org.harper.bookstore.domain.store.StoreSite.class);
	toSiteMapping.dontUseIndirection();
	toSiteMapping.addForeignKeyFieldName("store_transfer.to_site", "store_site.oid");
	descriptor.addMapping(toSiteMapping);
	
	OneToManyMapping itemsMapping = new OneToManyMapping();
	itemsMapping.setAttributeName("items");
	itemsMapping.setReferenceClass(org.harper.bookstore.domain.store.TransferItem.class);
	itemsMapping.useTransparentCollection();
	itemsMapping.useCollectionClass(oracle.toplink.indirection.IndirectList.class);
	itemsMapping.addTargetForeignKeyFieldName("store_trans_item.header", "store_transfer.oid");
	descriptor.addMapping(itemsMapping);
	
	return descriptor;
}

public ClassDescriptor buildTransferItemDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.store.TransferItem.class);
	descriptor.addTableName("store_trans_item");
	descriptor.addPrimaryKeyFieldName("store_trans_item.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("store_trans_item.oid");
	descriptor.setSequenceNumberName("store_trans_item");
	descriptor.setAlias("TransferItem");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	DirectToFieldMapping countMapping = new DirectToFieldMapping();
	countMapping.setAttributeName("count");
	countMapping.setFieldName("store_trans_item.count");
	descriptor.addMapping(countMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("store_trans_item.oid");
	descriptor.addMapping(oidMapping);
	
	OneToOneMapping bookMapping = new OneToOneMapping();
	bookMapping.setAttributeName("book");
	bookMapping.setReferenceClass(org.harper.bookstore.domain.profile.Book.class);
	bookMapping.dontUseIndirection();
	bookMapping.addForeignKeyFieldName("store_trans_item.book_oid", "profile_book.oid");
	descriptor.addMapping(bookMapping);
	
	OneToOneMapping headerMapping = new OneToOneMapping();
	headerMapping.setAttributeName("header");
	headerMapping.setReferenceClass(org.harper.bookstore.domain.store.Transfer.class);
	headerMapping.dontUseIndirection();
	headerMapping.addForeignKeyFieldName("store_trans_item.header", "store_transfer.oid");
	descriptor.addMapping(headerMapping);
	
	return descriptor;
}

public ClassDescriptor buildDeliveryOrderDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.deliver.DeliveryOrder.class);
	descriptor.addTableName("order_delivery");
	descriptor.addPrimaryKeyFieldName("order_delivery.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("order_delivery.oid");
	descriptor.setSequenceNumberName("order_delivery");
	descriptor.setAlias("DeliveryOrder");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	descriptor.addDirectMapping("valid", "order_delivery.valid");
	descriptor.addDirectMapping("sendMissed","order_delivery.send_missed");
	descriptor.addDirectMapping("remark","order_delivery.remark");
	
	DirectToFieldMapping statusMapping = new DirectToFieldMapping();
	statusMapping.setAttributeName("status");
	statusMapping.setFieldName("order_delivery.status");
	descriptor.addMapping(statusMapping);
	
	DirectToFieldMapping companyMapping = new DirectToFieldMapping();
	companyMapping.setAttributeName("company");
	companyMapping.setFieldName("order_delivery.company");
	companyMapping.setConverter(new EnumConverter(ExpressCompany.class,true));
	descriptor.addMapping(companyMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("order_delivery.oid");
	descriptor.addMapping(oidMapping);
	
	DirectToFieldMapping createDateMapping = new DirectToFieldMapping();
	createDateMapping.setAttributeName("createDate");
	createDateMapping.setFieldName("order_delivery.create_date");
	descriptor.addMapping(createDateMapping);
	
	DirectToFieldMapping numberMapping = new DirectToFieldMapping();
	numberMapping.setAttributeName("number");
	numberMapping.setFieldName("order_delivery.number");
	descriptor.addMapping(numberMapping);
	
	
	AggregateObjectMapping contactMapping = new AggregateObjectMapping();
	contactMapping.setAttributeName("contact");
	contactMapping.setReferenceClass(org.harper.bookstore.domain.profile.ContactInfo.class);
	contactMapping.addFieldNameTranslation("order_delivery.consignee_name", "name");
	contactMapping.addFieldNameTranslation("order_delivery.email", "email");
	contactMapping.addFieldNameTranslation("order_delivery.address", "address");
	contactMapping.addFieldNameTranslation("order_delivery.phone", "phone_normal");
	contactMapping.addFieldNameTranslation("order_delivery.mobile", "phone_mobile");
	contactMapping.addFieldNameTranslation("order_delivery.post_code", "post_code");
	contactMapping.dontAllowNull();
	descriptor.addMapping(contactMapping);
	
	OneToManyMapping itemsMapping = new OneToManyMapping();
	itemsMapping.setAttributeName("items");
	itemsMapping.setReferenceClass(org.harper.bookstore.domain.deliver.DeliveryItem.class);
	itemsMapping.privateOwnedRelationship();
	itemsMapping.useTransparentCollection();
	itemsMapping.useCollectionClass(oracle.toplink.indirection.IndirectList.class);
	itemsMapping.addTargetForeignKeyFieldName("order_delivery_item.header", "order_delivery.oid");
	descriptor.addMapping(itemsMapping);
	
	return descriptor;
}

public ClassDescriptor buildDeliveryItemDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.deliver.DeliveryItem.class);
	descriptor.addTableName("order_delivery_item");
	descriptor.addPrimaryKeyFieldName("order_delivery_item.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("order_delivery_item.oid");
	descriptor.setSequenceNumberName("order_delivery_item");
	descriptor.setAlias("DeliveryItem");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	DirectToFieldMapping returnedMapping = new DirectToFieldMapping();
	returnedMapping.setAttributeName("returned");
	returnedMapping.setFieldName("order_delivery_item.returned");
	descriptor.addMapping(returnedMapping);
	
	DirectToFieldMapping countMapping = new DirectToFieldMapping();
	countMapping.setAttributeName("count");
	countMapping.setFieldName("order_delivery_item.book_count");
	descriptor.addMapping(countMapping);
	
	DirectToFieldMapping unitCostMapping = new DirectToFieldMapping();
	unitCostMapping.setAttributeName("unitCost");
	unitCostMapping.setFieldName("order_delivery_item.unit_cost");
	descriptor.addMapping(unitCostMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("order_delivery_item.oid");
	descriptor.addMapping(oidMapping);
	
	OneToOneMapping headerMapping = new OneToOneMapping();
	headerMapping.setAttributeName("header");
	headerMapping.setReferenceClass(org.harper.bookstore.domain.deliver.DeliveryOrder.class);
	headerMapping.dontUseIndirection();
	headerMapping.addForeignKeyFieldName("order_delivery_item.header", "order_delivery.oid");
	descriptor.addMapping(headerMapping);
	
	OneToOneMapping orderItemMapping = new OneToOneMapping();
	orderItemMapping.setAttributeName("orderItem");
	orderItemMapping.setReferenceClass(org.harper.bookstore.domain.order.OrderItem.class);
	orderItemMapping.dontUseIndirection();
	orderItemMapping.addForeignKeyFieldName("order_delivery_item.item_oid", "order_item.oid");
	descriptor.addMapping(orderItemMapping);
	
	return descriptor;
}

public ClassDescriptor buildTodoItemDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.todo.TodoItem.class);
	descriptor.addTableName("todo_item");
	descriptor.addPrimaryKeyFieldName("todo_item.oid");
	
	// Descriptor Properties.
	descriptor.useFullIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteFullIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("todo_item.oid");
	descriptor.setSequenceNumberName("todo_item");
	descriptor.setAlias("TodoItem");
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	descriptor.addDirectMapping("oid", "todo_item.oid");
	descriptor.addDirectMapping("status", "todo_item.status");
	descriptor.addDirectMapping("subject", "todo_item.subject");
	descriptor.addDirectMapping("key","todo_item.biz_key");
	descriptor.addDirectMapping("content", "todo_item.content");
	descriptor.addDirectMapping("solution", "todo_item.solution");
	descriptor.addDirectMapping("privilege", "todo_item.privilege");
	descriptor.addDirectMapping("createDate", "todo_item.create_date");
	descriptor.addDirectMapping("dueDate", "todo_item.due_date");
	descriptor.addDirectMapping("resolveDate", "todo_item.resolve_date");
	
	return descriptor;
}

public ClassDescriptor buildStockTakingDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.store.StockTaking.class);
	descriptor.addTableName("store_stock_take");
	descriptor.addPrimaryKeyFieldName("store_stock_take.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("store_stock_take.oid");
	descriptor.setSequenceNumberName("store_stock_take");
	descriptor.setAlias("StockTaking");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	DirectToFieldMapping createDateMapping = new DirectToFieldMapping();
	createDateMapping.setAttributeName("createDate");
	createDateMapping.setFieldName("store_stock_take.create_date");
	descriptor.addMapping(createDateMapping);
	
	DirectToFieldMapping confirmDateMapping = new DirectToFieldMapping();
	confirmDateMapping.setAttributeName("confirmDate");
	confirmDateMapping.setFieldName("store_stock_take.confirm_date");
	descriptor.addMapping(confirmDateMapping);
	
	DirectToFieldMapping numberMapping = new DirectToFieldMapping();
	numberMapping.setAttributeName("number");
	numberMapping.setFieldName("store_stock_take.st_number");
	descriptor.addMapping(numberMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("store_stock_take.oid");
	descriptor.addMapping(oidMapping);
	
	DirectToFieldMapping statusMapping = new DirectToFieldMapping();
	statusMapping.setAttributeName("status");
	statusMapping.setFieldName("store_stock_take.status");
	descriptor.addMapping(statusMapping);
	
	OneToOneMapping siteMapping = new OneToOneMapping();
	siteMapping.setAttributeName("site");
	siteMapping.setReferenceClass(org.harper.bookstore.domain.store.StoreSite.class);
	siteMapping.dontUseIndirection();
	siteMapping.addForeignKeyFieldName("store_stock_take.site", "store_site.oid");
	descriptor.addMapping(siteMapping);
	
	OneToManyMapping itemsMapping = new OneToManyMapping();
	itemsMapping.setAttributeName("items");
	itemsMapping.setReferenceClass(org.harper.bookstore.domain.store.StockTakingItem.class);
	itemsMapping.useTransparentCollection();
	itemsMapping.useCollectionClass(oracle.toplink.indirection.IndirectList.class);
	itemsMapping.addTargetForeignKeyFieldName("store_stock_take_item.header", "store_stock_take.oid");
	descriptor.addMapping(itemsMapping);
	
	return descriptor;
}

public ClassDescriptor buildStockTakingItemDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.store.StockTakingItem.class);
	descriptor.addTableName("store_stock_take_item");
	descriptor.addPrimaryKeyFieldName("store_stock_take_item.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("store_stock_take_item.oid");
	descriptor.setSequenceNumberName("store_stock_take_item");
	descriptor.setAlias("StockTakingItem");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	DirectToFieldMapping currentCountMapping = new DirectToFieldMapping();
	currentCountMapping.setAttributeName("currentCount");
	currentCountMapping.setFieldName("store_stock_take_item.current_count");
	descriptor.addMapping(currentCountMapping);
	
	DirectToFieldMapping originCountMapping = new DirectToFieldMapping();
	originCountMapping.setAttributeName("originCount");
	originCountMapping.setFieldName("store_stock_take_item.expect_count");
	descriptor.addMapping(originCountMapping);
	
	DirectToFieldMapping unitPriceMapping = new DirectToFieldMapping();
	unitPriceMapping.setAttributeName("unitPrice");
	unitPriceMapping.setFieldName("store_stock_take_item.unit_price");
	descriptor.addMapping(unitPriceMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("store_stock_take_item.oid");
	descriptor.addMapping(oidMapping);
	
	OneToOneMapping bookMapping = new OneToOneMapping();
	bookMapping.setAttributeName("book");
	bookMapping.setReferenceClass(org.harper.bookstore.domain.profile.Book.class);
	bookMapping.dontUseIndirection();
	bookMapping.addForeignKeyFieldName("store_stock_take_item.book_oid", "profile_book.oid");
	descriptor.addMapping(bookMapping);
	
	OneToOneMapping headerMapping = new OneToOneMapping();
	headerMapping.setAttributeName("header");
	headerMapping.setReferenceClass(org.harper.bookstore.domain.store.StockTaking.class);
	headerMapping.dontUseIndirection();
	headerMapping.addForeignKeyFieldName("store_stock_take_item.header", "store_stock_take.oid");
	descriptor.addMapping(headerMapping);
	
	return descriptor;
}

public ClassDescriptor buildStockAlertDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.store.StockAlert.class);
	descriptor.addTableName("store_stock_alert");
	descriptor.addPrimaryKeyFieldName("store_stock_alert.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("store_stock_alert.oid");
	descriptor.setSequenceNumberName("store_stock_alert");
	descriptor.setAlias("StockAlert");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	descriptor.addDirectMapping("warnThreshold","store_stock_alert.warn_threshold");
	descriptor.addDirectMapping("errorThreshold","store_stock_alert.error_threshold");
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("store_stock_alert.oid");
	descriptor.addMapping(oidMapping);
	
	OneToOneMapping siteMapping = new OneToOneMapping();
	siteMapping.setAttributeName("site");
	siteMapping.setReferenceClass(org.harper.bookstore.domain.store.StoreSite.class);
	siteMapping.dontUseIndirection();
	siteMapping.addForeignKeyFieldName("store_stock_alert.site", "store_site.oid");
	descriptor.addMapping(siteMapping);
	
	OneToOneMapping bookMapping = new OneToOneMapping();
	bookMapping.setAttributeName("book");
	bookMapping.setReferenceClass(org.harper.bookstore.domain.profile.Book.class);
	bookMapping.dontUseIndirection();
	bookMapping.addForeignKeyFieldName("store_stock_alert.book_oid", "profile_book.oid");
	descriptor.addMapping(bookMapping);
	
	return descriptor;
}

public ClassDescriptor buildUserDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.user.User.class);
	descriptor.addTableName("profile_user");
	descriptor.addPrimaryKeyFieldName("profile_user.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("profile_user.oid");
	descriptor.setSequenceNumberName("profile_user");
	descriptor.setAlias("User");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	descriptor.addDirectMapping("id","profile_user.id");
	descriptor.addDirectMapping("oid","profile_user.oid");
	descriptor.addDirectMapping("encryptedPass","profile_user.ency_pass");
	descriptor.addDirectMapping("lastLoginDate","profile_user.last_login_date");

	
	return descriptor;
}

public ClassDescriptor buildReceiveOrderDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.deliver.ReceiveOrder.class);
	descriptor.addTableName("order_receive");
	descriptor.addPrimaryKeyFieldName("order_receive.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("order_receive.oid");
	descriptor.setSequenceNumberName("order_receive");
	descriptor.setAlias("ReceiveOrder");
	
	VersionLockingPolicy vp = new VersionLockingPolicy();
	vp.setIsStoredInCache(false);
	vp.setWriteLockFieldName("order_receive.version");
//	descriptor.setOptimisticLockingPolicy(vp);
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	descriptor.addDirectMapping("receiveDate","order_receive.receive_date");
	descriptor.addDirectMapping("remark","order_receive.remark");
	descriptor.addDirectMapping("type","order_receive.type");
	descriptor.addDirectMapping("refNumber","order_receive.ref_number");
	
	DirectToFieldMapping createDateMapping = new DirectToFieldMapping();
	createDateMapping.setAttributeName("createDate");
	createDateMapping.setFieldName("order_receive.create_date");
	descriptor.addMapping(createDateMapping);
	
	DirectToFieldMapping numberMapping = new DirectToFieldMapping();
	numberMapping.setAttributeName("number");
	numberMapping.setFieldName("order_receive.number");
	descriptor.addMapping(numberMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("order_receive.oid");
	descriptor.addMapping(oidMapping);
	
	DirectToFieldMapping companyMapping = new DirectToFieldMapping();
	companyMapping.setAttributeName("company");
	companyMapping.setFieldName("order_receive.company");
	companyMapping.setConverter(new EnumConverter(ExpressCompany.class,true));
	descriptor.addMapping(companyMapping);
		
	DirectToFieldMapping statusMapping = new DirectToFieldMapping();
	statusMapping.setAttributeName("status");
	statusMapping.setFieldName("order_receive.status");
	descriptor.addMapping(statusMapping);
	
	OneToOneMapping siteMapping = new OneToOneMapping();
	siteMapping.setAttributeName("site");
	siteMapping.setReferenceClass(org.harper.bookstore.domain.store.StoreSite.class);
	siteMapping.dontUseIndirection();
	siteMapping.addForeignKeyFieldName("order_receive.site", "store_site.oid");
	descriptor.addMapping(siteMapping);
	
	AggregateObjectMapping contactMapping = new AggregateObjectMapping();
	contactMapping.setAttributeName("sender");
	contactMapping.setReferenceClass(org.harper.bookstore.domain.profile.ContactInfo.class);
	contactMapping.addFieldNameTranslation("order_receive.sender_name", "name");
	contactMapping.addFieldNameTranslation("order_receive.sender_email", "email");
//	contactMapping.addFieldNameTranslation("order_receive.address", "address");
	contactMapping.addFieldNameTranslation("order_receive.sender_phone", "phone_normal");
	contactMapping.addFieldNameTranslation("order_receive.sender_mobile", "phone_mobile");
//	contactMapping.addFieldNameTranslation("order_receive.post_code", "post_code");
	contactMapping.dontAllowNull();
	descriptor.addMapping(contactMapping);
	
	OneToOneMapping deliveryMapping = new OneToOneMapping();
	deliveryMapping.setReferenceClass(org.harper.bookstore.domain.deliver.DeliveryOrder.class);
	deliveryMapping.setAttributeName("delivery");
	deliveryMapping.dontUseIndirection();
	deliveryMapping.addForeignKeyFieldName("order_receive.delivery", "order_delivery.oid");
	descriptor.addMapping(deliveryMapping);
	
	OneToManyMapping itemsMapping = new OneToManyMapping();
	itemsMapping.setAttributeName("items");
	itemsMapping.setReferenceClass(org.harper.bookstore.domain.deliver.ReceiveItem.class);
	itemsMapping.privateOwnedRelationship();
	itemsMapping.useTransparentCollection();
	itemsMapping.useCollectionClass(oracle.toplink.indirection.IndirectList.class);
	itemsMapping.addTargetForeignKeyFieldName("order_receive_item.header", "order_receive.oid");
	descriptor.addMapping(itemsMapping);
	
	return descriptor;
}

public ClassDescriptor buildReceiveOrderItemDescriptor() {
	RelationalDescriptor descriptor = new RelationalDescriptor();
	descriptor.setJavaClass(org.harper.bookstore.domain.deliver.ReceiveItem.class);
	descriptor.addTableName("order_receive_item");
	descriptor.addPrimaryKeyFieldName("order_receive_item.oid");
	
	// Descriptor Properties.
	descriptor.useSoftCacheWeakIdentityMap();
	descriptor.setIdentityMapSize(100);
	descriptor.useRemoteSoftCacheWeakIdentityMap();
	descriptor.setRemoteIdentityMapSize(100);
	descriptor.setSequenceNumberFieldName("order_receive_item.oid");
	descriptor.setSequenceNumberName("order_receive_item");
	descriptor.setAlias("ReceiveItem");
	
	
	// Query Manager.
	descriptor.getQueryManager().checkCacheForDoesExist();
	
	
	// Event Manager.
	
	// Mappings.
	DirectToFieldMapping unitCostMapping = new DirectToFieldMapping();
	unitCostMapping.setAttributeName("unitCost");
	unitCostMapping.setFieldName("order_receive_item.unit_cost");
	descriptor.addMapping(unitCostMapping);
	
	DirectToFieldMapping countMapping = new DirectToFieldMapping();
	countMapping.setAttributeName("count");
	countMapping.setFieldName("order_receive_item.count");
	descriptor.addMapping(countMapping);
	
	DirectToFieldMapping oidMapping = new DirectToFieldMapping();
	oidMapping.setAttributeName("oid");
	oidMapping.setFieldName("order_receive_item.oid");
	descriptor.addMapping(oidMapping);
	
	OneToOneMapping bookMapping = new OneToOneMapping();
	bookMapping.setAttributeName("book");
	bookMapping.setReferenceClass(org.harper.bookstore.domain.profile.Book.class);
	bookMapping.dontUseIndirection();
	bookMapping.addForeignKeyFieldName("order_receive_item.book_oid", "profile_book.oid");
	descriptor.addMapping(bookMapping);
	
	OneToOneMapping orderMapping = new OneToOneMapping();
	orderMapping.setAttributeName("header");
	orderMapping.setReferenceClass(org.harper.bookstore.domain.deliver.ReceiveOrder.class);
	orderMapping.dontUseIndirection();
	orderMapping.addForeignKeyFieldName("order_receive_item.header", "order_receive.oid");
	descriptor.addMapping(orderMapping);
	
	return descriptor;
}
}
